package ym.ecrm.core.dto.systemManagement;

import java.lang.reflect.InvocationTargetException;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.struts2.views.jsp.BeanTag;

import ym.ecrm.core.domain.systemManagement.Resource;

public class ResourceDTO {

	private long resourceId;
	private String resourceCode;
	private String roleName;
	private String type;
	
	public static void entity2dto(Resource resource, ResourceDTO resourceDTO){
		try {
			BeanUtils.copyProperties(resourceDTO, resource);
			resourceDTO.setResourceId(resource.getId());
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			e.printStackTrace();
		}
		
	}
	
	public static void dto2entity(ResourceDTO resourceDTO, Resource resource){
		try {
			BeanUtils.copyProperties(resource, resourceDTO);
			resource.setId(resourceDTO.getResourceId());
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			e.printStackTrace();
		}
	}

	public long getResourceId() {
		return resourceId;
	}

	public void setResourceId(long resourceId) {
		this.resourceId = resourceId;
	}

	public String getResourceCode() {
		return resourceCode;
	}

	public void setResourceCode(String resourceCode) {
		this.resourceCode = resourceCode;
	}

	public String getRoleName() {
		return roleName;
	}

	public void setRoleName(String roleName) {
		this.roleName = roleName;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}
	
}
